import { Inject } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { BannerInfoEntity } from '../../entity/info';
import { BannerInfoService } from '../../service/info';
import { BannerCategoryEntity } from '../../entity/category';

/**
 * 轮播图信息
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: BannerInfoEntity,
  service: BannerInfoService,
  pageQueryOp: {
    keyWordLikeFields: ['a.title'],
    fieldEq: ['a.status', 'a.categoryId'],
    join: [
      {
        entity: BannerCategoryEntity,
        alias: 'b',
        condition: 'a.categoryId = b.id',
        type: 'leftJoin',
      },
    ],
    select: ['a.*', 'b.name as categoryName'],
  },
})
export class AdminBannerInfoController extends BaseController {
  @Inject()
  bannerInfoService: BannerInfoService;
}
